package com.diaosidadui.array;

import java.util.Scanner;

public class Score {
    /*
    打分系统
     */
    public static void main(String[] args) {
        //输入6个分数,去掉1个最大值和一个最小值,然后求出平均分
        Scanner sc = new Scanner(System.in);
        double[] scoreArray = new double[6];

        //遍历数组,输入分数
        for (int i = 0; i < scoreArray.length; i++) {
            //scoreArray[i]
            System.out.println("请输入第" + (i + 1) + "个分数:");
            double score = sc.nextInt();
            if (score < 0 || score > 100) {
                System.out.println("输入有误,请重新输入");
                i--;
            } else {
                scoreArray[i] = score;
            }
        }

        double sum = 0, max = scoreArray[0], min = scoreArray[0];
        //遍历数组,取出总分,最大分,最小分
        for (int i = 0; i < scoreArray.length; i++) {
            sum += scoreArray[i];
            max = max > scoreArray[i] ? max : scoreArray[i];
            min = min < scoreArray[i] ? min : scoreArray[i];

        }
        //平均分=(总分-最大份-最小分)/4
        double avg =(sum-max-min)/4;
        System.out.println("最后得分:"+avg);

    }


}
